import * as apiService from '@/services/api';

/**
 * 记录操作日志
 * @param params
 * @returns {Promise<*>}
 */
const logAddApi = params => apiService.post(api.SYS_LOG_ADD, params);

/**
 * 取得操作日志列表
 * @param params
 * @returns {Promise<*>}
 */
const logListApi = (params) => {
  if (params.date) {
    params = _.clone(params);
    params.startTime = _.toTime(params.date[0]);
    params.endTime = _.toTime(params.date[1]);
  }
  return apiService.post(api.SYS_LOG_LIST, params);
};

/**
 * 获取所有部门列表
 * @returns {Promise<*>}
 */
const departmentListApi = () => apiService.post(api.SYS_DEPARTMENT_LIST);

/**
 * 取得系统参数设置
 * @returns {Promise<*>}
 */
const systemConfigureGetApi = () => apiService.post(api.SYS_CONFIGURE_GET);

/**
 * 保存系统参数设置
 * @return {Promise<*>}
 * @param regTime
 * @param regNum
 * @param loginTime
 */
const systemConfigureSaveApi = ({ regTime, regNum, loginTime }) => apiService.post(api.SYS_CONFIGURE_SAVE,
  { regTime, regNum, loginTime });

/**
 * 取得系统接口设置
 * @returns {Promise<*>}
 * @param apiType
 */
const systemInterfaceGetApi = ({ apiType }) => apiService.post(api.SYS_INTERFACE_GET, { apiType });
/**
 * 取得系统接口设置
 * @returns {Promise<*>}
 * @param apiType
 */
const systemInterfaceUpdateStatus = ({ id, status, apiType }) => apiService.post(api.SYS_INTERFACE_UPDATE, { id, status, apiType });

/**
 * 保存系统接口设置
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemInterfaceSaveApi = ({
  id, url, template, open,
}) => apiService.post(api.SYS_INTERFACE_UPDATE,
  {
    id, url, template, open,
  });
/**
 * 保存手机版本更新设置
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemAppVersionSaveApi = params => apiService.post(api.SYS_APP_VERSION_SAVE, params);
/**
 * 获取手机版本更新列表
 * @param sameIpCount
 * @return {Promise<*>}
 */
const appVersionListApi = params => apiService.post(api.APP_VERSION_LIST, params);
/**
 * 删除手机版本更新
 * @param sameIpCount
 * @return {Promise<*>}
 */
const deleteVersionApi = params => apiService.post(api.APP_VERSION_DELETE, params);
/**
 * ipaboundid列表
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemIpaList = params => apiService.post(api.SYS_IPA_LIST, params);
/**
 * ipaboundid添加
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemIpaAdd = params => apiService.post(api.SYS_IPA_ADD, params);
/**
 * ipaboundid失效
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemIpaClose = params => apiService.post(api.SYS_IPA_CLOSE, params);
/**
 * ipaboundid生效
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemIpaOpen = params => apiService.post(api.SYS_IPA_OPEN, params);
/**
 * 删除ipaboundid
 * @param sameIpCount
 * @return {Promise<*>}
 */
const systemIpaDelete = params => apiService.post(api.SYS_IPA_DELETE, params);


// 注册管理
/**
 * 查询开关状态
 * @param sameIpCount
 * @return {Promise<*>}
 */
const registerOnOffStatus = () => apiService.post(api.SYS_REGIST_ONOFF_STATUS);
/**
 * 修改开关状态
 * @param sameIpCount
 * @return {Promise<*>}
 */
const registerChangeOnOffStatus = params => apiService.post(api.SYS_REGIST_ONOFF_SAVE, params);
/**
 * 查询配置
 * @param sameIpCount
 * @return {Promise<*>}
 */
const registerConfig = () => apiService.post(api.SYS_REGIST_CONFIG);
/**
 * 修改配置
 * @param sameIpCount
 * @return {Promise<*>}
 */
const registerChangeConfig = params => apiService.post(api.SYS_REGIST_CONFIG_SAVE, params);

/**
 * 限制充值时获取手机/银行卡相关信息
 * @param sameIpCount
 * @return {Promise<*>}
 */
const checkOnOffStatus = params => apiService.post(api.SYS_CHECK_ONOFF_SAVE, params);

/**
 * 客服切换api
 * @param key
 * @returns {Promise<*|*|*|undefined>}
 */
const customerServiceApi = ({ key }) => apiService.post(api.CS_SWITCH_API, {key});

/**
 * 获取客服切换配置
 * @returns {Promise<*|*|*|undefined>}
 */
const customerServiceGetApi = () => apiService.post(api.CS_SWITCH_GET);

export {
  logAddApi,
  logListApi,
  departmentListApi,
  systemConfigureSaveApi,
  systemConfigureGetApi,
  systemInterfaceGetApi,
  systemInterfaceSaveApi,
  systemInterfaceUpdateStatus,
  systemAppVersionSaveApi,
  appVersionListApi,
  deleteVersionApi,
  systemIpaList,
  systemIpaAdd,
  systemIpaClose,
  systemIpaOpen,
  systemIpaDelete,
  registerOnOffStatus,
  registerChangeOnOffStatus,
  registerConfig,
  registerChangeConfig,
  checkOnOffStatus,
  customerServiceApi,
  customerServiceGetApi
};
